﻿using System;
using System.ComponentModel.DataAnnotations;

namespace assignment1
{
    class fuction
    {
        public bool q4isToeplitz(int[,] a)
        {
            int col = a.GetLength(1);
            int row = a.GetLength(0);
            if (a.Length == 1 || col == 1) return true;
            for (int j = 0; j < col; j++)
            {
                int tem = a[0, j];
                int x = 0, y = j;
                while (++x < row && ++y < col)
                {
                    if (a[x, y] != tem) return false;
                }
            }
            for (int i = 0; i < row; i++)
            {
                int tem = a[i, 0];
                int x = i, y = 0;
                while (++x < row && ++y < col)
                {
                    if (a[x, y] != tem) return false;
                }
            }
            return true;
        }
    }
    class ExecuteFunction
    {
        static void Main(string[] args)
        {
            fuction f = new fuction();

            //q4
            int[,] a = new int[,] { { 1, 2, 3, 4 }, { 5, 1, 2, 3 }, { 9, 5, 1, 2 } };
            int[,] b = new int[,] { { 1, 2, 3, 4 }, { 5, 1, 2, 3 }, { 9, 5, 1, 3 } };
            Console.WriteLine(f.q4isToeplitz(a));
            Console.WriteLine(f.q4isToeplitz(b));

        }
    }
}
